package com.walter.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.walter.domain.TeacherInfo;
import com.walter.service.TeacherInfoService;
import com.walter.service.impl.TeacherInfoServiceImpl;

public class TeacherPageServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private TeacherInfoService ts = new TeacherInfoServiceImpl();

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 获取第几页
		String page0 = request.getParameter("page");
		int page = Integer.parseInt(page0);
		// 1.调用Service查询所有客户
		// List<TeacherInfo> list = ts.getAll();
		long count = ts.getCount();
		List<TeacherInfo> list = ts.getAllByPage(page);
		// 2.将客户列表放入request域
		request.setAttribute("list", list);
		request.setAttribute("count", count);
		// 3.转发到list.jsp显示

		request.getRequestDispatcher("/jsp/index.jsp").forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}